Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve test suite, reorganize to platform classes #26

Merged
merged 10 commits into from
Jul 22, 2021
Merged

Improve test suite, reorganize to platform classes #26

merged 10 commits into from
Jul 22, 2021

Conversation

gaborbernat
Copy link
Member

@gaborbernat gaborbernat commented Jul 20, 2021

Managed to close #25 by mistake so opening again.

gaborbernat and others added 2 commits July 20, 2021 10:34
Signed-off-by: Bernát Gábor <gaborjbernat@gmail.com>
Signed-off-by: Bernát Gábor <bgabor8@bloomberg.net>
@codecov-commenter
Copy link

codecov-commenter commented Jul 20, 2021

Codecov Report

Merging #26 (2f20866) into main (9735757) will increase coverage by 5.94%.
The diff coverage is 87.17%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main      #26      +/-   ##
==========================================
+ Coverage   83.69%   89.64%   +5.94%     
==========================================
  Files           7       12       +5     
  Lines         411      425      +14     
  Branches       85       43      -42     
==========================================
+ Hits          344      381      +37     
+ Misses         47       31      -16     
+ Partials       20       13       -7     
Flag Coverage Δ
tests 89.17% <86.58%> (+5.96%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
src/platformdirs/windows.py 66.29% <66.29%> (ø)
src/platformdirs/unix.py 73.07% <73.07%> (ø)
src/platformdirs/__init__.py 100.00% <100.00%> (+21.26%) ⬆️
src/platformdirs/android.py 100.00% <100.00%> (ø)
src/platformdirs/api.py 100.00% <100.00%> (ø)
src/platformdirs/macos.py 100.00% <100.00%> (ø)
tests/conftest.py 100.00% <100.00%> (ø)
tests/test_android.py 100.00% <100.00%> (ø)
tests/test_api.py 100.00% <100.00%> (ø)
tests/test_comp_with_appdirs.py 100.00% <100.00%> (ø)
... and 6 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 9735757...2f20866. Read the comment docs.

@gaborbernat gaborbernat changed the title main Improve test suite, reorganize to platform classes Jul 20, 2021
@gaborbernat gaborbernat marked this pull request as ready for review July 20, 2021 13:49
path = os.environ["XDG_DATA_DIRS"]
else:
path = f"/usr/local/share{os.pathsep}/usr/share"
return self._with_multi_path(path)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not work with split paths here and only join the result

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you detail? I've just kept the existing method, but we can switch if you propose something better.


def _path_with_app_version(self, path: str, *, opinion_value: Optional[str] = None) -> str:
if self.appname:
assert self.appname is not None

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this seems redundant at first glance

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmmm, kept existing logic, but yeah this can be removed.

Signed-off-by: Bernát Gábor <bgabor8@bloomberg.net>
@ofek
Copy link
Collaborator

ofek commented Jul 20, 2021

This looks fine but I'd much prefer to keep the conditional detection logic. I have a bias b/c I write a lot of CLIs where load times are important, but really why should we import every module at the root when only one will be used?

@gaborbernat
Copy link
Member Author

gaborbernat commented Jul 20, 2021

This looks fine but I'd much prefer to keep the conditional detection logic. I have a bias b/c I write a lot of CLIs where load times are important, but really why should we import every module at the root when only one will be used?

Can you provide some metrics of a performance difference? I don't think there's a significant difference in importing three small files. What you're talking about is premature optimization?

@ofek
Copy link
Collaborator

ofek commented Jul 20, 2021

Not an issue currently, but we'd have to careful with imports in each module. Say for example we're on not-Android and a new Python release made importing functools slower, things like that.

premature optimization

I don't think so as the 2 approaches are so different that going back to the current one by removing .is_active methods would be a breaking change.

@gaborbernat
Copy link
Member Author

I don't think so as the 2 approaches are so different that going back to the current one by removing .is_active methods would be a breaking change.

I'd definitely keep is_active. At that point, you'd have different solutions to use import functools locally where it's needed.

Signed-off-by: Bernát Gábor <bgabor8@bloomberg.net>
@gaborbernat
Copy link
Member Author

@ofek added d94e998 to achieve a similar functionality 👍

Signed-off-by: Bernát Gábor <bgabor8@bloomberg.net>
Signed-off-by: Bernát Gábor <bgabor8@bloomberg.net>
Copy link
Collaborator

@ofek ofek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks much nicer ty 😄

Signed-off-by: Bernát Gábor <bgabor8@bloomberg.net>
Signed-off-by: Bernát Gábor <bgabor8@bloomberg.net>
docs/api.rst Outdated Show resolved Hide resolved
Signed-off-by: Bernát Gábor <bgabor8@bloomberg.net>
@RonnyPfannschmidt
Copy link

Unfortunately im quite stretched today and can't give this quite the time it deserves

src/platformdirs/api.py Outdated Show resolved Hide resolved
src/platformdirs/api.py Outdated Show resolved Hide resolved
src/platformdirs/api.py Outdated Show resolved Hide resolved
src/platformdirs/api.py Outdated Show resolved Hide resolved
src/platformdirs/api.py Outdated Show resolved Hide resolved
src/platformdirs/api.py Outdated Show resolved Hide resolved
src/platformdirs/api.py Outdated Show resolved Hide resolved
class MacOS(PlatformDirsABC):
"""
Platform directories for the macOS operating system. Follows the guidance from `Apple documentation
<https://developer.apple.com/library/archive/documentation/FileManagement/Conceptual/FileSystemProgrammingGuide/MacOSXDirectories/MacOSXDirectories.html>`_.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you move the URL to the end of the parragraph as done here?

This helps keep the docstring more readable in it's raw format.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I disagree in this instance, I prefer to keep links inline 👍

src/platformdirs/macos.py Outdated Show resolved Hide resolved
src/platformdirs/macos.py Outdated Show resolved Hide resolved
tox.ini Show resolved Hide resolved
Signed-off-by: Bernát Gábor <bgabor8@bloomberg.net>
@gaborbernat gaborbernat merged commit 6fe8168 into tox-dev:main Jul 22, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants